using PlayMyLife.Definitions.HumanProperty;
using PlayMyLife.ViewCommon;
using PlayMyLife.Events;
using PlayMyLife.ViewModel;
using UnityEngine;
using UnityEngine.UI;

namespace PlayMyLife.View.Prefabs {
    public class PreparationPanel : FormBase {
        [SerializeField] private Toggle tgNameTypeCN;
        [SerializeField] private Toggle tgNameTypeEU;
        [SerializeField] private InputField ifFirstName;
        [SerializeField] private InputField ifLastName;
        [SerializeField] private Toggle tgGenderMale;
        [SerializeField] private Toggle tgGenderFemale;
        [SerializeField] private Dropdown ddBirthMonth;
        [SerializeField] private Dropdown ddBirthDay;
        [SerializeField] private Dropdown ddMbtiType;

        [SerializeField] private GameObject[] hideAtFirstPlay;
        [SerializeField] private GameObject[] showAtFirstPlay;

        protected override void OnOpen() {
            
        }

        protected override void OnClose() {

        }

        public void OnClickPrev() {
            GameViewManager.EventMgr.NotifyAsync(new EventArgs_ClosePanel(PanelType.PreparationPanel));
            GameViewManager.EventMgr.NotifyAsync(new EventArgs_ShowPanel(PanelType.StartPanel, PanelLayer.FullScreen));
        }

        public void OnClickNext() {
            Name name;
            if(tgNameTypeCN.isOn) {
                name = new Name(ifFirstName.text, ifLastName.text, NameType.LastIsReal, "");
            } else {
                name = new Name(ifFirstName.text, ifLastName.text, NameType.FirstIsReal, " ");
            }
            var gender = tgGenderFemale.isOn ? GenderType.Female : GenderType.Male;
            var birthMonth = 7;
            var birthDay = 8;
            var mbti = MbtiType.INFJ;
            GameViewManager.EventMgr.NotifyAsync(new EventArgs_ClosePanel(PanelType.PreparationPanel));
            GameViewManager.EventMgr.NotifyAsync(new EventArgs_LoadGame(name, gender, birthMonth, birthDay, mbti));
        }
    }
}
